1. Field of the Invention
The invention relates to a method for forming blocks from a digital bit stream and an apparatus for the same.
2. Description of the Related Art
There is a method whereby a digital bit stream is recorded as it is onto a recording medium such as a recordable DVD (Digital Versatile Disc) and the recorded digital bit stream is simply reproduced from the recording medium. As a digital bit stream, for example, MPEG2-TS (Moving Picture Experts Group 2-Transport Stream) can be used. Usually, data showing the contents of one of a plurality of programs has been multiplexed in the stream on a packet unit basis and it is called “Full TS”. A transfer rate is set to 20 to 30 Mbps or more.
Assuming that the packets of Full TS are sequential like P1, P2, P3, . . . with respect to time as shown in FIG. 1A, a program is designated by the user at the time of recording onto a recording medium and, thereafter, the packet corresponding to the designated program is selected. Assuming that the packets corresponding to the program selected by the user designation are the hatched packets P1, P3, P6, P9, . . . among the packets P1, P2, P3, . . . in FIG. 1A, blanks on time exist among the packets as shown in FIG. 1B, respectively. The above stream is called “Partial TS”. In the Partial TS, in the case of programs of the standard television system, a transfer rate per program is equal to about 4 to 9 Mbps although it depends on the contents of the program. The Partial TS is recorded onto the recording medium such as a DVD.
As for a time interval between the packets of the Partial TS, although the interval upon recording has to be held at the time of playing the recording medium, it is improper to record the blank time of the Partial TS as it is onto the recording medium in terms of a capacity of the recording medium. Since it is necessary to record time information showing the blank time in some form, therefore, in a digital stream recorder, the arrival time of the packet of the Partial TS is added as time stamp information of a predetermined number of bytes to the head of each packet as shown in FIG. 1C and it is recorded onto the recording medium without a gap. As a storing format for recording, for example, a private 2 of MPEG2-PS (program stream) can be mentioned in consideration of the recording onto the DVD. As will be explained hereinlater, stream identification information is added to the stream in order to recognize the private stream.
Upon reproduction of the recording medium, the value of the time stamp information is detected and the packets are transmitted in accordance with its detecting timing. That is, each packet is transmitted in a state where the blank time between the respective packets upon recording has perfectly been reconstructed. The transmitted packets are supplied to an MPEG decoder, the data of the packet is decoded, and a reproduction signal of the selected program is generated.
A recording area of the recording medium is divided into a plurality of sectors and the packet is recorded in each sector. For example, one sector consists of 2048 bytes corresponding to one sector length for the DVD. As shown in FIG. 2, a pack header, a PES header, stream ID (identification) information, an application header, an additional data portion, and a main data portion are formed from the beginning in one sector. A plurality of time stamps (TS) and a plurality of packets are recorded in the main data portion. A length of packet is the length of packet in the Partial TS and is equal to 188 bytes.
The pack header and the PES header conform with the MPEG standard. As mentioned above, as stream ID information, the ID information used for recognizing the private stream in the video recording is used. Information such as the number of packets in the sector, length of packet, and the like is recorded in the application header. The additional data portion is an area where random access information or the like is recorded and additional information of z bytes is provided for one packet. When k packets exist in the sector, the additional data portion consists of (z×k) bytes.
Although the data is recorded in the main data portion in a state where the time stamps have been added to the packets, a length of main data portion is not equal to the length that is integer times as long as the length in which the time stamps have been added to the packets. Since the packets are sequentially filled in the sector from the supplied packets, the beginning bit of the time stamp is not always recorded to the start position of the main data portion. A partial packet is rather located in each of the start and end portions of the main data portion as shown in FIG. 3. The partial packet of the start portion is a continuing portion of the partial packet of the end portion of the main data portion of the previous sector. As for the partial packet, the values of the length and the like thereof are recorded in the application header.
Assuming that one sector consists of the same number of bytes, namely, 2048 bytes as that of the DVD or the like, each portion has the following length.                Pack header: 14 bytes        PES header: 6 bytes        Stream ID information: 1 byte        Application header: j bytes        Additional data portion: z bytes per packet        1 packet+1 time stamp: s+t bytesEach of the pack header, PES header, stream ID information, and application header always has the fixed length.        
When 10 packets are recorded in the main data portion of a sector, it has a length of {21+j+(z+s+t)×10} bytes. A remainder area of [2048{21+j+(z+s+t)×10}] bytes, therefore, occurs in the sector and it is allocated to the partial packet.
When the next packet and its time stamp are allocated to the remainder area, also with respect to the partial packet, z bytes for the additional data portion are added after the additional data portion of 10×z bytes. That is, the additional data portion consists of 11×z bytes, so that the number of bytes of the partial packet and its time stamp is actually set [2048−{21+j+(z+s+t)×10}−z] bytes. The remaining portion of the partial packet is located after the additional data portion of the next sector.
When the data of each sector is sequentially formed by the above method, the number of space bytes in a sector of a certain designated number is equal to or less than z bytes. If the space bytes are allocated to the additional data portion, the remaining bytes disappear due to the space bytes alone as shown in FIG. 4. One byte of each of the time stamp and the packet main body of the next packet cannot be allocated to this sector. There is, consequently, a possibility of the occurrence of an error when the data of this sector is read out and reproduced.
The above problem occurs in the case where a bit train consisting of y bytes of the digital bit stream is divided as one packet into blocks each having a predetermined length and stored into a storage apparatus such as a hard disk or the like.
In the case, the main data portion where a plurality of packets are stored and the additional data portion corresponding to each packet before the main data portion are provided for each block. The additional data portion shows the data such as random access information of every packet of the main data portion and each additional data is, for example, data of one byte.
Assuming that only k packets each consisting of y bytes can be formed in the main data portion in a complete state, only k+1 additional data each consisting of z bytes is formed in the additional data portion, and the packets are arranged from the main data portion of the first block without a gap, in the main data portion of the i-th block, the remaining portion of the last packet, namely, the partial packet n of the main data portion in the (i-1)-th block is located first as shown in FIG. 5. The complete packets n+1, n+2, . . . , and n+k are subsequently arranged. The packet n+k+1 is arranged in a partial form into the remaining blank portion of the main data portion in the order of the bits. Additional data 1 corresponding to the packet n+1, additional data 2 corresponding to the packet n+2, additional data k corresponding to the packet n+k, and additional data k+1 corresponding to the packet n+k+1 are arranged in the additional data portion. The value of k changes in dependence on the number of bytes in the remaining portion of the partial packet n.
Assuming that a size of one block is equal to B bytes, sinceB=(k+1)×z+k×y+(the number of bytes of the partial packets n and n+k+1),the following equation has to be satisfied.(The number of bytes of the partial packets n and n+k+1)=B−{(k+1)×z+k×y}If the number of bytes in the remaining portion of the partial packet n is equal to [B ˜{(k+1)×z+k×y}], therefore, the data of the partial packet n+k+1 cannot be provided in the main data portion as shown in FIG. 6.
That is, such an inconvenience that the packet n+k+1 becomes the block in which no byte exists in spite of the fact that the additional data k+1 regarding the partial packet n+k+1 exists in the additional data portion occurs. If the data is recorded by the above block, there is such a possibility that an error occurs at the time of a reproducing process and the original digital bit stream cannot be reproduced.